package com.fansl.allround.study.designpattern.responsibilitychain;

/**
 * @author fansl
 * @Description: TODO
 * @date 2019/10/11 14:47
 */
public class HandlerChainFactory {
    private static Handler handler;

    public static Handler doLeaveChain(){
        if (handler==null){
            try {
                Handler groupLeaveNoteHandler = new GroupLeaveNoteHandler();
                Handler leaderLeaveNoteHandler = new LeaderLeaveNoteHandler();
                leaderLeaveNoteHandler.setNextHandler(groupLeaveNoteHandler);
                Handler ceoLeaveNoteHandler= new CEOLeaveNoteHandler();
                ceoLeaveNoteHandler.setNextHandler(leaderLeaveNoteHandler);
                handler = groupLeaveNoteHandler;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return handler;
    }
}
